package com.blog.controller.interceptor;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class EncodeInterceptor implements Interceptor {

	@Override
	public void destroy() {
		System.out.println("EncodeInterceptor-->destroy");
	}

	@Override
	public void init() {
		System.out.println("EncodeInterceptor-->init");
	}

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		HttpServletResponse response = ServletActionContext.getResponse();
		// Ajax乱码 编码格式
		response.setContentType("text/html;charset=utf-8");

		
		
		return invocation.invoke();
	}

}
